<!--
 * @Author: yuanweijiang
 * @Date: 2025-02-11 15:19:41
 * @LastEditors: yuanweijiang
-->
<template>
	<el-dialog title="新增分组" width="800" v-model="visible" :close-on-click-modal="false" :destroy-on-close="true" draggable>
		<ApiGroupEdit @submitForm="createApiGroup" :initialApiGroup="apiGroup" />
	</el-dialog>
</template>

<script setup lang="ts">
import ApiGroupEdit from './components/ApiGroupEdit.vue';
import request from '/@/utils/request111';
import { ElMessage } from 'element-plus';
const visible = ref(false);
const apiGroup = ref({});
const emit = defineEmits(['refresh']);

function createApiGroup(apiGroup) {
	let config = { method: 'POST', body: apiGroup };
	request('/api/sys/api-groups', config).then((response) => {
		if (response.ok) {
			ElMessage.success('新增成功！');
			visible.value = false;
			emit('refresh');
		}
	});
}

function openDialog() {
	visible.value = true;
	apiGroup.value = {};
}
defineExpose({
	openDialog,
});
</script>

<style scoped></style>
